﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net.Sockets;

namespace ggprot
{
    public class GGUserDataAttrib
    {
        private int nameSize;
        private string name;
        private int type;
        private int valueSize;
        private string value;

        public string Value
        {
            get { return this.value; }
            set { this.value = value; }
        }

        public int ValueSize
        {
            get { return valueSize; }
            set { valueSize = value; }
        }

        public int Type
        {
            get { return type; }
            set { type = value; }
        }

        public string Name
        {
            get { return name; }
            set { name = value; }
        }

        public int NameSize
        {
            get { return nameSize; }
            set { nameSize = value; }
        }

        public void Read(NetworkStream stream)
        {
            BinaryReader reader = new BinaryReader(stream);

            nameSize = reader.ReadInt32();
            name = String.Concat(reader.ReadChars(nameSize));
            type = reader.ReadInt32();
            valueSize = reader.ReadInt32();
            value = String.Concat(reader.ReadChars(valueSize));
        }
    }
}
